<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>AUI快速完成布局</title>
    <link rel="stylesheet" type="text/css" href="../aui/css/aui.css" />
    <script type="text/javascript" src="/static/js/jquery-1.10.1.min.js"></script>
    <script type="text/javascript" src="/static/js/template-web.js"></script>
    <!-- [EasyUI] -->
    <link id="easyuiTheme" rel="stylesheet" type="text/css" href="/static/jquery-easyui-1.5.1/themes/gray/easyui.css" />
    <link id="easyuiTheme" rel="stylesheet" type="text/css" href="/static/jquery-easyui-1.5.1/themes/icon.css" />
    <script type="text/javascript" src="/static/jquery-easyui-1.5.1/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="/static/jquery-easyui-1.5.1/locale/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" src="/static/js/HhUtil.js?t=20170109"></script>
    <!-- [扩展样式] -->
    <link rel="stylesheet" type="text/css" href="/static/css/dreamlu.css" />
    <link rel="stylesheet" type="text/css" href="/static/css/icommon.css" />
    <link rel="stylesheet" type="text/css" href="/static/css/login.css" />
</head>
<body>
<div style="margin:0 10%;width:80%" >
    <a href="javascript:void(0);" class="easyui-linkbutton"
       data-options="iconCls:'icon-search',plain:true" onclick="get_all();">查看全部</a>
    <a href="javascript:void(0);" class="easyui-linkbutton"
       data-options="iconCls:'icon-cancel',plain:true" onclick="get_top();">只看置顶</a>
</div>

<div id="main" style="margin:0 10%;width:80%"></div>
<div id="push_more" onclick="push_more_circe()" class="aui-col-xs-12" style="text-align:center">
    <p>拉取更多</p>
    <i class="aui-iconfont aui-icon-down"></i>
</div>

</body>
<script id="circle_info" type="text/html">
{{each info as item i}}
<div class="aui-card-list">
        <div class="aui-card-list-header aui-card-list-user aui-border-b">
            <div class="aui-card-list-user-avatar">
                <img src="{{ item.avatar }}" class="aui-img-round" />
            </div>
            <div class="aui-card-list-user-name">
                <div>{{ item.nick_name }}</div>
                {{ if item.is_silence == 1 }}
                    <small class="silence{{ item.phone }}" onclick="set_silence({{ item.phone }},{{ item.c_id }}, 1)">取消禁言</small>
                {{ else}}
                    <small class="silence{{ item.phone }}" onclick="set_silence({{ item.phone }},{{ item.c_id }}, 0)">禁言</small>
                {{/if}}
            </div>
            <div class="aui-card-list-user-info">{{ item.create_time }}</div>
        </div>
        <div class="aui-card-list-content-padded">
            {{ item.text }}
        </div>

        <div class="aui-card-list-content-padded aui-border-b aui-border-t">
            <div class="aui-row aui-row-padded">
                {{ each item.images as img j}}
                <div class="aui-col-xs-1" style="height: 100px">
                    <img src="{{ img }}" style="height:100%;"/>
                </div>
                {{/each}}
            </div>
        </div>

        <div class="aui-card-list-footer aui-border-t">
            <div onclick="direct2replylist({{item.c_id}})"><i class="aui-iconfont aui-icon-note"></i> {{ item.reply_cnt }}</div>
            <div><i class="aui-iconfont aui-icon-laud"></i> {{ item.zan_cnt }}</div>
            {{ if item.is_using == 1 }}
                <div id="div{{ item.c_id }}" onclick="chan_circle_status({{ item.c_id }}, 1)"><span id="span{{ item.c_id }}">屏蔽</span></div>
            {{ else }}
                <div id="div{{ item.c_id }}" onclick="chan_circle_status({{ item.c_id }}, 2)"><span id="span{{ item.c_id }}">取消屏蔽</span></div>
            {{/if}}

            {{ if item.is_top == 1 }}
                <div id="top{{ item.c_id }}" onclick="chan_circle_top({{ item.c_id }}, 1)"> 取消置顶</div>
            {{ else }}
                <div id="top{{ item.c_id }}" onclick="chan_circle_top({{ item.c_id }}, 0)"> 置顶</div>
            {{/if}}
        </div>
    </div>
{{/each}}
</script>

<script type="text/javascript">

    function direct2replylist(c_id){
        location.href="reply_list.html?c_id="+c_id;
    }

    function push_more_circe(c_id) {
        $.ajax( {
            url:'/couchcirclelist',// 跳转到 action
            data:{
                     c_id : c_id
            },
            type:'post',
            cache:false,
            dataType:'json',
            success:function(data) {
                if(data.code =="0" ){
                    var html = template('circle_info',data);
                    $("#push_more").attr("onclick", "push_more_circe("+data.last_id+")")
                    $("#main").html($("#main").html()+html);
                }else{
                    view(data.msg);
                }
             },
             error : function() {
                  // view("异常！");
                  alert("异常！");
             }
        });
    }


    function set_silence(phone, c_id, is_silence) {
        if (is_silence == 1){
            $.ajax( {
                url:'/setsilence',// 跳转到 action
                data:{
                         phone : phone,
                         is_silence : 0
                },
                type:'post',
                cache:false,
                dataType:'json',
                success:function(data) {
                    if(data.code =="0" ){
                        $(".silence"+phone).attr("onclick", "set_silence("+phone+","+c_id+", 0)")
                        $(".silence"+phone).html("禁言")
                    }else{
                        view(data.msg);
                    }
                 },
                 error : function() {
                      // view("异常！");
                      alert("异常！");
                 }
            });
        }else{
            $.ajax( {
                url:'/setsilence',// 跳转到 action
                data:{
                         phone : phone,
                         is_silence : 1
                },
                type:'post',
                cache:false,
                dataType:'json',
                success:function(data) {
                    if(data.code =="0" ){
                        $(".silence"+phone).attr("onclick", "set_silence("+phone+","+c_id+", 1)")
                        $(".silence"+phone).html("取消禁言")
                    }else{
                        view(data.msg);
                    }
                 },
                 error : function() {
                      // view("异常！");
                      alert("异常！");
                 }
            });

        }
    }


    function chan_circle_top(c_id, is_top) {
        if (is_top == 1){
            $.ajax( {
                url:'/circletop',// 跳转到 action
                data:{
                         c_id : c_id,
                         is_top : 0
                },
                type:'post',
                cache:false,
                dataType:'json',
                success:function(data) {
                    if(data.code =="0" ){
                        $("#top"+c_id).attr("onclick", "chan_circle_top("+c_id+", 0)")
                        $("#top"+c_id).html("置顶")
                    }else{
                        view(data.msg);
                    }
                 },
                 error : function() {
                      // view("异常！");
                      alert("异常！");
                 }
            });
        }else{
            $.ajax( {
                url:'/circletop',// 跳转到 action
                data:{
                         c_id : c_id,
                         is_top : 1
                },
                type:'post',
                cache:false,
                dataType:'json',
                success:function(data) {
                    if(data.code =="0" ){
                        $("#top"+c_id).attr("onclick", "chan_circle_top("+c_id+", 1)")
                        $("#top"+c_id).html("取消置顶")
                    }else{
                        view(data.msg);
                    }
                 },
                 error : function() {
                      // view("异常！");
                      alert("异常！");
                 }
            });

        }
    }

    function chan_circle_status(c_id, is_using) {
        if (is_using == 1){
            $.ajax( {
                url:'/circlestatus',// 跳转到 action
                data:{
                         c_id : c_id,
                         is_using : 2
                },
                type:'post',
                cache:false,
                dataType:'json',
                success:function(data) {
                    if(data.code =="0" ){
                        $("#div"+c_id).attr("onclick", "chan_circle_status("+c_id+", 2)")
                        $("#span"+c_id).html("取消屏蔽")
                    }else{
                        view(data.msg);
                    }
                 },
                 error : function() {
                      // view("异常！");
                      alert("异常！");
                 }
            });
        }else{
            $.ajax( {
                url:'/circlestatus',// 跳转到 action
                data:{
                         c_id : c_id,
                         is_using : 1
                },
                type:'post',
                cache:false,
                dataType:'json',
                success:function(data) {
                    if(data.code =="0" ){
                        $("#div"+c_id).attr("onclick", "chan_circle_status("+c_id+", 1)")
                        $("#span"+c_id).html("屏蔽")
                    }else{
                        view(data.msg);
                    }
                 },
                 error : function() {
                      // view("异常！");
                      alert("异常！");
                 }
            });

        }

    }


    function get_all() {
        $.ajax( {
            url:'/couchcirclelist',// 跳转到 action
            type:'post',
            cache:false,
            dataType:'json',
            success:function(data) {
                if(data.code =="0" ){
                    var html = template('circle_info',data);
                    $("#main").html("").html(html);
                    $("#push_more").attr("onclick", "push_more_circe("+data.last_id+")")
                }else{
                    view(data.msg);
                }
             },
             error : function() {
                  // view("异常！");
                  alert("异常！");
             }
        });
    }

    function get_top() {
        $.ajax( {
            url:'/couchcirclelist',// 跳转到 action
            type:'post',
            cache:false,
            data: {
                type: 'top'
            },
            dataType:'json',
            success:function(data) {
                if(data.code =="0" ){
                    var html = template('circle_info',data);
                    $("#main").html("").html(html);
                    $("#push_more").attr("onclick", "push_more_circe("+data.last_id+")")
                }else{
                    view(data.msg);
                }
             },
             error : function() {
                  // view("异常！");
                  alert("异常！");
             }
        });
    }

    get_all()




</script>
</html>